By Brent Simmons
Once you get over the shock -- Emacs on a Mac? -- you want to get under the hood and see how Apple's OS X (10.1) stacks up against Linux.
There's an immediate temptation to invent a recursive acronym to describe the difference. How about OIG -- OsX Isn't GNU? Every OS needs an animal. A large neutered farm beast might not be Apple's style, but why leave it up to them? They're too anal anyway, insisting we call it "OS ten" rather than "OS ex".
The ox metaphor certainly applies, in a very positive way, to Darwin [1], the new and still-evolving UNIX platform on which the rest of OS X sits. Based on BSD and the Mach 3.0 kernel, Darwin is a legitimate UNIX variant, no less inviting than any other open source OS. It even runs on x86 hardware, if you like.
Cupertino Command Line
"Write programs that do one thing and do it well. Write programs to work together. Write programs that handle text streams, because that is a universal interface." That's how Dennis Ritchie explained the UNIX "toolbox" philosophy nearly thirty years ago. Since theng UNIX has always been a box of tools that obeys text commands.
When you come to Darwin in its native habitat (one of the slick new Macs that ship with OS X) you go for the Terminal in /Applications/Utilities, and you're in. Do a cd /;ls and you'll find familiar directories -- bin, etc, sbin, tmp, Users, usr, var -- alongside others such as Applications, Library, Trash, and so on.
Look in /usr/bin and many of the tools you expect to find are there: autoconf, bison, cvs, fetchmail, nslookup, perl, ssh, whoami, and so on. It's new territory, but familiar enough.
The unexpected tools come, of course, from from the Mac side of OS X's heritage. One example is osascript, which lets you run an AppleScript script from the command line -- a feat one imagines the original AppleScript designers may not have envisioned.
And certain usual suspects are missing: no Python or Pine, for instance. But these are itches open source developers are free to scratch, which is exactly what some are doing. The OSXGNU [2] archive already includes Python, bash (the OS X default is tcsh), Pine, and Lynx. So their absence from the Apple-supplied version of the OS is easily corrected.
The Fink [3] project distributes ports of ant, MySQL, nmap, Ruby, and so on, with the stated intent to make OS X "a coherent, comfortable distribution that matches what Linux users are used to." They add, "Fink uses Debian tools like dpkg and apt-get to provide powerful binary package management. You can choose whether you want to download precompiled binary packages or build everything from source."
It's interesting to discover that much of the software included with OS X is BSD- or MIT-licensed, while much of the software one downloads is GPLed. Though that's a just a rule of thumb, it's a definite contrast between OS X and Linux. For example, OS X comes with Curl [4], available under the MIT license, rather than the more familiar GPL-licensed GNU Wget [5]. This may owe to an alergy to GPL-licensed software in Apple's legal department.
Ready to serve, sort of
Though there is a separate OS X Server, OS X itself includes server software such as Apache, sendmail, named, and sshd. AppleTalk and Samba support are built-in.
Since OS X is so new, kinks are still being discovered. For example, a security issue was uncovered in Apache, since HFS+, the Mac's native file system, is not case-sensitive. This meant a URL that would otherwise be denied would be made readable just by changing the case of the request. Apple responded with a new Apache module that enforces pseudo-case-sensitivity -- and which any build instructions [6] for Apache on OS X must take into account.
And when you see the administrative interface for these servers, you suddenly realize anew that you're using a Mac. IT Manager and Mac columnist John C. Welch calls OS X an "okay server, mostly due to hardware limitations and immaturity," while "Linux is an excellent server. It runs on more, and better hardware than Windows can ever dream of, thanks to IBM and Sun."
In the beginning was the GUI
Macs are backwards: it took the company more than twenty-five years to get a command line. Meanwhile Apple popularized, defined and redefined GUI desktop computing, even while Microsoft ran away with the dominant market share. With OS X, Apple does it again. The difference this time is that you can operate in either a command line or a GUI mode. For Linux geeks this separates the Apple wheat from the Microsoft chaff. Finally there's a desktop OS that's real where it counts.
There are, of course, GUI ways of doing command line work. Some of them aren't bad. Turning on Apache is easy in the GUI, whether you call it a dumbing down, or an ingenious interface designed to work for the greatest number of people. Just open System Preferences (by default there's an icon in the Dock, which is Apple's radically different approach to organizing items you want minimized on the desktop), click on the Sharing icon, then click Start to turn on "Web Sharing" (Apache). You can turn on FTP and ssh access the same way. [Note: if there's room, a screenshot is here.] The command line is still there, of course. Just edit /etc/httpd/httpd.conf with your favorite editor, and you'll feel at home.
The GUI is called Aqua, named for its watery, gum-droppy look, which includes variably translucent windows and other stuff Microsoft can copy later. It includes a file browser (still called Finder) that resembles both the Classic Mac OS and the NeXT multi-column file browser, depending on how you use it. Most GUI apps are stored in /Applications. It's worth noting that one founding UNIX sensibility OS X brings to the desktop is a relatively rigid hierarchical directory schema. Users in the past could scatter apps and documents wherever they pleased. With OS X, apps go in the Applications directory and documents go in the user's own Documents subdirectory. This may be one reason Nicholas Riley says, "I still can't imagine my parents using 10.1."
In the OS X Applications directory you find with a small pile of free-as-in-beer closed source apps, mostly from Apple. Some, such as iTunes and iMovie, do what Apple has always done best, which is expand both GUI art and ease of use to levels its competitors can never quite reach. Others, such as Apple's Mail app, calculator and clock, are handy placeholders. There are free-beer third-party apps too, including one that many Linux geeks would rather avoid: Microsoft's Internet Explorer. Fortunately a native OS X version of Netscape 6.2 (based on Mozilla) is a download away, and appears to work quite well. So does the latest Mozilla 0.9..5+ build. Opera is still in beta.
The portfolio of available apps for OS X is still small, relative to Windows and even to MacOS Classic (which OS X runs in emulation). But it's growing fast. BBEdit (which Mac geeks regard as the greatest text editor ever) is out. So is Adobe Illustrator 10. And now there's an all-new Microsoft Office that some believe leapfrogs the latest Windows version of the suite. This is sure to make OS X far more popular (and, we sarcastically suspect, its command-line interface even more necessary).
It would be a mistake to discount the importance of Microsoft Office for the world's GUI-dependent population. Without current and file-compatible Macintosh versions of Microsoft Office, Apple would surely have died. So think of Office as a kind of life support until the GUI world breaks free of Office's various file formats. Also consider an Apple advantage: If you want to run Word or Excel natively, OS X is your only choice.
All of this illustrates the extremely mixed nature of OS X in the layers above Darwin. Little of OS X above its UNIX foundation is open source, although Apple has gone out of its way to invite and incorporate changes and improvements recommended by anybody who's interested -- something that Apple never would have done before Steve Jobs returned (with his UNIX-oriented NeXT team). One report said upwards of 70,000 recommendations were sent to Apple during in the public beta period alone, which began in November 2000, and many were incorporated throughout OS X -- to the degree that some have suggested the current OS be renamed OS XI.
One of the most significant changes during the beta period was a new source code license for Darwin. The original license basically said, "you can improve it any way you want as long as only we get to use the results." That license was one of the first casualties of the public beta program, along with the attitude that produced it. Within two months, Apple came out with a BSD-like license that the Open Source Initiative has since added to its approved list. Not long afterwards Chris Bourdon, OS X's product manager, told Linux Journal, "You can take Darwin and do anything you like. It's there for everybody."
So, while Apple is still far from being an orthodox open source company, it is making significant moves in the right direction, even while traditional open source companies such as VA Linux are moving the other way by coming out with closed source products.
Apple has also introduced some perhaps welcome consistencies that bridge the GUI and command line environments. Brad Cox says, "The big draw is user interface consistency. Cmd-C is copy and Cmd-V is paste everywhere, unlike that cheesy select-for-copy/middle-click-for-paste of Linux which often does nothing at all. And BBEdit 6.5 is wonderful, steadily drawing me away from vim. Desktop apps work flawlessly, unlike flaky wannabes like Abiword and StarOffice." On the other hand (or part of one), Linux geeks feel like they're missing fingers when they try to cope with Apple's one-button mouse, which has never appeared on any hardware other than Apple's. Fortunately, there are 3-button USB mice for the Mac, and appropriate drivers as well. Each to their own.
In any case, progress is mostly positive:
Developer Nirvana?
With every retail copy of OS X Apple ships a Developer Tools CD. Included are the familiar cc and gdb along with Project Builder and Interface Builder, an IDE and user interface layout tool. This is a huge change. To develop for Macs prior to OS X one had to purchase MPW (Macintosh Programmers Workshop) tools from Apple, or CodeWarrior from Metrowerks.
Project Builder and Interface Builder have generated a lot of enthusiasm. Says Graeme Hiebert, "Project Builder is a very nice IDE, and Interface Builder is an amazing piece of work. Prior to Mac OS X, I've been pretty much a makefile guy, but I rarely use them any more."
Gabriel Ricard says, "What I love the most about PB and IB is that I don't have to write a single line of code to create the interface. I just use IB to create the interface, write the classes and their selectors that the interface is attached to in IB, and build the app."
For writing GUI apps, one has a choice of writing to the Carbon [14] APIs, which are a revision of the classic Mac APIs, or using Cocoa [15], which is an updated version of the NeXT frameworks. Carbon is the best bet for Mac developers porting classic apps to OS X since it requires the fewest code changes. Cocoa is recommended for new apps. Cocoa apps can be written in Objective-C or in Java. Objective-C is, like C++, a superset of C.
Aside from Carbon and Cocoa apps, one can also create command-line tools, kernel extensions, plugins, pure Java apps, and frameworks with Project Builder.
Extensive examples, tutorials, and documentation are also included with the developer tools. However, these might not be extensive enough: some developers have called it "lousy" and "not really up to par yet."
While Apple seems to want you to develop for OS X, occasionally you run across things like this from the Darwin developer documentation [16]: "If you are thinking of writing code for the kernel environment, think carefully. Programming in the kernel can be a difficult and dangerous task. And often there is a way to accomplish what you want to do without touching the kernel... kernel software is a real pain to write."
While that might be true, the meta-message is that there are shields up around the kernel. Note, however, that there is outside participation. Not all the kernel hacking is by Apple employees. See, for example, the list of Darwin Committers [17].
But unless kernel hacking is what you really want to do, OS X can be developer nirvana. The UNIX tools and scripting languages you're used to are there, and Project Builder and Interface Builder make building GUI apps relatively painless (once you learn the Cocoa frameworks).
Remember that this is the company that hit a home run with HyperCard by putting programming within reach of hobbyists and home users. The OS X equivalent of HyperCard may be AppleScript Studio [18]. Not yet available at this writing, it promises "a set of professional application development tools featuring complete interface design and script writing with step-by-step debugging and source management."
Another candidate is REALbasic [19], which creates stand-alone apps for OS X, Classic MacOS (even Windows) and has a reputation for being easy to use and easy to learn. In his article "REALbasic for HyperCard Users," [19] Matt Neuburg writes, "the Apple folks never really understood the brilliance of HyperCard, or how essential it was to the user community."
Perhaps that's changing now, with the inclusion of the Developer Tools CD, new apps that allow one to rapidly developer user interfaces, and OS X's Open Source, UNIX foundation.
Which means the OS will only get stronger. Like, well, an ox.
Brent Simmons is an experienced UNIX, Linux and MacOS programmer who works for Userland Software and lives near Linux Journal in the beautiful Ballard district of Seattle.
***Links
[1] Darwin: http://www.publicsource.apple.com/projects/darwin/
[2] OSXGNU: http://www.osxgnu.org/software/index.html
[3] Fink: http://fink.sourceforge.net/
[4] Curl: http://curl.haxx.se/
[5] Wget: http://www.gnu.org/software/wget/wget.html
[6] build instructions: http://www.stepwise.com/Articles/Workbench/2001-10-11.01.html
[7] Microsoft Office: http://www.microsoft.com/mac/officex/default.asp
[8] X on X project: http://sourceforge.net/projects/xonx
[9] GNOME: http://fink.sourceforge.net/pdb/section.php/gnome
[10] OroborosX: http://wrench.et.ic.ac.uk/adrian/software/oroborosx/
[11] GIMP: http://www.macgimp.org/
[12] Open Office to OS X: http://porting.openoffice.org/mac/
[13] slow going: http://www.zdnet.com/zdnn/stories/news/0,4586,2784625,00.html
[14] Carbon: http://developer.apple.com/techpubs/macosx/Carbon/carbon.html
[15] Cocoa: http://developer.apple.com/techpubs/macosx/Cocoa/CocoaTopics.html
[16] Darwin developer documentation: http://developer.apple.com/techpubs/macosx/Darwin/ShouldYou.html
[17] Darwin committers: http://www.opensource.apple.com/developer/developers.html
[18] AppleScript Studio: http://www.apple.com/applescript/macosx/ascript_studio/
[19] REALbasic for HyperCard Users: http://www.oreillynet.com/pub/a/mac/2001/09/20/realbasic.html
[19] REALbasic: http://www.realbasic.com/